/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.widgets;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.jdesktop.beansbinding.Converter;

/**
 *
 * @author david
 */
public class DateConverter extends Converter<Date, String> {

    private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MMM-yyyy");

    @Override
    public String convertForward(Date value) {
        return DATE_FORMAT.format(value);
    }

    @Override
    public Date convertReverse(String value) {
        try {
            return DATE_FORMAT.parse(value);
        } catch (ParseException ex) {
            return null;
        }
    }
}
